# Maintainer: Konstantin Gizdov <arch at kge dot pw>
# Contributor: Eric Förster <eric DOT foerster AT outlook DOT com>
# Contributor: Patrick Förster <patrick DOT foerster AT outlook DOT de>

pkgname=texlab
pkgver=5.4.1
pkgrel=1
pkgdesc="A cross-platform implementation of the Language Server Protocol for LaTeX."
arch=('loong64' 'x86_64')
url="https://texlab.netlify.com"
license=('MIT')
depends=('gcc-libs')
makedepends=('cargo' 'npm')
source=("${pkgname}-${pkgver}.tar.gz::https://github.com/latex-lsp/texlab/archive/v${pkgver}.tar.gz")
b2sums=('f4f7a3184515516cf20c7a5fa4528de8ff5b0203f8211fc450a0722db6d3f8a7864f9b9be6dd9aa66671330f91ec7443533a37eef8cb4d18789ffe52474dd552')
options=('!lto')

prepare() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
}

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  export RUSTUP_TOOLCHAIN=stable
  export CARGO_TARGET_DIR=target
  cargo build --frozen --release --all-features
}

check() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  export RUSTUP_TOOLCHAIN=stable
  cargo test --frozen --all-features
}

package() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  install -Dm 755 "target/release/${pkgname}" "${pkgdir}/usr/bin/${pkgname}"
  install -Dm 644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}
